package com.sun.syndication.feed.module.wcm;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import com.sun.syndication.feed.module.ModuleImpl;
import com.sun.syndication.feed.module.wcm.types.Component;
import com.sun.syndication.feed.module.wcm.types.Path;
import com.sun.syndication.feed.module.wcm.types.TemplateMap;
/**
 * 
 * <p>This file is extracted from Websphere Portal 6.1 FeedServiceWCPPlugin.jar
 * 
 * <p>Original class is <code>com.ibm.workplace.feed.plugin.wcm.module.WCMModuleImpl</code>
 *
 */
public class WCMModuleImpl extends ModuleImpl implements WCMModule {

	public WCMModuleImpl() {
		super(WCMModule.class,
				"http://purl.org/net/ibmfeedsvc/wcm/1.0");
		contentComponents = new HashMap();
	}

	public Date getPublicationDate() {
		return publishDate;
	}

	public String getContentType() {
		return contentType;
	}

	public String getWorkflowStage() {
		return workflowStage;
	}

	public Date getExpirationDate() {
		return expirationDate;
	}

	public String getAction() {
		return action;
	}

	public String getLibrary() {
		return library;
	}

	public String getDisplayTitle() {
		return displayTitle;
	}

	public List getLocations() {
		return location != null ? location : (location = new ArrayList());
	}

	public List getUserEntitlements() {
		return userEntitlement != null ? userEntitlement
				: (userEntitlement = new ArrayList());
	}

	public String getObjectType() {
		return objectType;
	}

	public List getAuthors() {
		return authors != null ? authors : (authors = new ArrayList());
	}

	public String getKeywords() {
		return keywords;
	}

	public String getWorkflow() {
		return workflow;
	}

	public List getAddlViewers() {
		return addlViewers != null ? addlViewers
				: (addlViewers = new ArrayList());
	}

	public List getChildren() {
		return children != null ? children : (children = new ArrayList());
	}

	public String getChildrenAction() {
		return childrenAction;
	}

	public String getChildrenPosition() {
		return childrenPosition;
	}

	public String getDefaultContent() {
		return defaultContent;
	}

	public List getTmpltMaps() {
		return tmpltMaps != null ? tmpltMaps
				: (tmpltMaps = new ArrayList());
	}

	public List getManagerEntitlements() {
		return managerEntitlement != null ? managerEntitlement
				: (managerEntitlement = new ArrayList());
	}

	public List getEditorEntitlements() {
		return editorEntitlement != null ? editorEntitlement
				: (editorEntitlement = new ArrayList());
	}

	public Date getGenDateOne() {
		return genDateOne;
	}

	public Date getGenDateTwo() {
		return genDateTwo;
	}

	public List getOwners() {
		return owners != null ? owners : (owners = new ArrayList());
	}

	public List getParents() {
		return parents != null ? parents : (parents = new ArrayList());
	}

	public List getContributorEntitlements() {
		return contributorEntitlement != null ? contributorEntitlement
				: (contributorEntitlement = new ArrayList());
	}

	public Object get(String p_name) {
		return contentComponents.get(p_name);
	}

	public void setPublicationDate(Date p_value) {
		publishDate = p_value;
	}

	public void setContentType(String p_value) {
		contentType = p_value;
	}

	public void setWorkflowStage(String p_value) {
		workflowStage = p_value;
	}

	public void setExpirationDate(Date p_value) {
		expirationDate = p_value;
	}

	public void setAction(String p_value) {
		action = p_value;
	}

	public void setLibrary(String p_value) {
		library = p_value;
	}

	public void setDisplayTitle(String p_value) {
		displayTitle = p_value;
	}

	public void setLocations(List p_value) {
		location = p_value;
	}

	public void setUserEntitlements(List p_value) {
		userEntitlement = p_value;
	}

	public void setObjectType(String p_value) {
		objectType = p_value;
	}

	public void setAuthors(List p_value) {
		authors = p_value;
	}

	public void setKeywords(String p_value) {
		keywords = p_value;
	}

	public void setWorkflow(String p_value) {
		workflow = p_value;
	}

	public void setAddlViewers(List p_value) {
		addlViewers = p_value;
	}

	public void setChildren(List p_value) {
		children = p_value;
	}

	public void setChildrenAction(String p_value) {
		childrenAction = p_value;
	}

	public void setChildrenPosition(String p_value) {
		childrenPosition = p_value;
	}

	public void setDefaultContent(String p_value) {
		defaultContent = p_value;
	}

	public void setTmpltMaps(List p_value) {
		tmpltMaps = p_value;
	}

	public void setManagerEntitlements(List p_value) {
		managerEntitlement = p_value;
	}

	public void setEditorEntitlements(List p_value) {
		editorEntitlement = p_value;
	}

	public void setGenDateOne(Date p_value) {
		genDateOne = p_value;
	}

	public void setGenDateTwo(Date p_value) {
		genDateTwo = p_value;
	}

	public void setOwners(List p_value) {
		owners = p_value;
	}

	public void setParents(List p_value) {
		parents = p_value;
	}

	public void setContributorEntitlements(List p_value) {
		contributorEntitlement = p_value;
	}

	public void set(String p_name, Object p_value) {
		contentComponents.put(p_name, p_value);
	}

	public HashMap getComponents() {
		return contentComponents;
	}

	public Class getInterface() {
		return WCMModule.class;
	}

	public void copyFrom(Object obj) {
		WCMModule wm = (WCMModule) obj;
		List authors = new ArrayList(wm.getAuthors());
		setAuthors(authors);
		List owners = new ArrayList(wm.getOwners());
		setOwners(owners);
		setAction(wm.getAction());
		setContentType(wm.getContentType());
		setObjectType(wm.getObjectType());
		setKeywords(wm.getKeywords());
		List children = new ArrayList(wm.getChildren());
		setChildren(children);
		setChildrenAction(wm.getChildrenAction());
		setChildrenPosition(wm.getChildrenPosition());
		List parents = new ArrayList(wm.getParents());
		setParents(parents);
		List otherLocations = wm.getLocations();
		List locations = new ArrayList();
		for (Iterator iter = otherLocations.iterator(); iter.hasNext();) {
			Path loc = (Path) iter.next();
			try {
				locations.add(loc.clone());
			} catch (CloneNotSupportedException e) {
				e.printStackTrace();
			}
		}

		setLocations(locations);
		setDefaultContent(wm.getDefaultContent());
		List otherTmpltMaps = wm.getTmpltMaps();
		List tmpltMaps = new ArrayList();
		for (Iterator iter = otherTmpltMaps.iterator(); iter.hasNext();) {
			TemplateMap map = (TemplateMap) iter.next();
			try {
				tmpltMaps.add(map.clone());
			} catch (CloneNotSupportedException e) {
				e.printStackTrace();
			}
		}

		setTmpltMaps(tmpltMaps);
		setWorkflow(wm.getWorkflow());
		setWorkflowStage(wm.getWorkflowStage());
		setPublicationDate((Date) wm.getPublicationDate().clone());
		setExpirationDate((Date) wm.getExpirationDate().clone());
		setGenDateOne((Date) wm.getGenDateOne().clone());
		setGenDateTwo((Date) wm.getGenDateTwo().clone());
		List addlViewers = new ArrayList(wm.getAddlViewers());
		setAddlViewers(addlViewers);
		List userMembers = new ArrayList(wm.getUserEntitlements());
		setUserEntitlements(userMembers);
		List contributorMembers = new ArrayList(wm.getContributorEntitlements());
		setContributorEntitlements(contributorMembers);
		List managerMembers = new ArrayList(wm.getManagerEntitlements());
		setManagerEntitlements(managerMembers);
		List editorMembers = new ArrayList(wm.getEditorEntitlements());
		setEditorEntitlements(editorMembers);
		HashMap compMap = wm.getComponents();
		for (Iterator iter = compMap.keySet().iterator(); iter.hasNext();) {
			String componentName = (String) iter.next();
			Component component = (Component) compMap.get(componentName);
			try {
				set(componentName, component.clone());
			} catch (CloneNotSupportedException e) {
				e.printStackTrace();
			}
		}

	}

	public static final long serialVersionUID = 1L;
	private List authors;
	private List owners;
	private String displayTitle;
	private String objectType;
	private String contentType;
	private String library;
	private List location;
	private List parents;
	private List children;
	private String childrenAction;
	private String childrenPosition;
	private String defaultContent;
	private List tmpltMaps;
	private String keywords;
	private String workflow;
	private String workflowStage;
	private Date publishDate;
	private Date expirationDate;
	private Date genDateOne;
	private Date genDateTwo;
	private List addlViewers;
	private List userEntitlement;
	private List contributorEntitlement;
	private List editorEntitlement;
	private List managerEntitlement;
	private String action;
	private HashMap contentComponents;
}
